package com.dongdongshop_util;

/*
* 统一返回结果封装
* */
public class Result {

    private Integer code;
    private String message;
    private Object data;

    public Result(){
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result success(ResultEnum resultEnum,Object data){
        return new Result(resultEnum.getCode(),resultEnum.getMessage(),data);
    }
    public static Result perfect(ResultEnum resultEnum){
        return new Result(resultEnum.getCode(),resultEnum.getMessage());
    }

    public static Result response(ResultEnum resultEnum){
        return new Result(resultEnum.getCode(),resultEnum.getMessage());
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
